<template>
	<view>
		<cu-custom bgColor="bg-gradual-orange" :isBack="true">
			<block slot="content"></block>
		</cu-custom>
		<!-- 背景圖 -->
		<image class="backImage" src="https://app.yycjkb.cn/index/fujiajia/111.png" mode="widthFix"></image>

		<view class="container">
			<!-- 用戶信息 -->
			<view class="user-info">
				<view class="user-info-left">
					<image v-if="userInfo.luohan==1" class="user-info-image" src="/static/luohan.png" mode="aspectFill">
					</image>
					<image v-else class="user-info-image" :src="userInfo.avatar || '/static/default_avatar.png'"
						mode=""></image>
					<view class="user-info-name" v-if="hasLogin">
						<view class="name">{{userInfo.nickname}}</view>
						<view class="info">
							<view class="uid">UID:{{userInfo.id}} <text class="user-copy" @tap.stop="copy">复制</text>
							</view>
							<view class="contribute">贡献值:{{userInfo.contribute}}</view>
							<view class="contribute" v-if="(userInfo.user_level==2 || userInfo.user_level==3)">
								流量券：{{userInfo.contribution}}</view>
						</view>
					</view>

					<view class="user-info-name" v-if="!hasLogin">
						<button class="login-btn" @tap="jumpTo('/pages/my/login', 'inside', false)"
							v-if="!hasLogin">点击登录</button>
					</view>
				</view>
				<view class="user-info-right">
					<!-- https://app.yycjkb.cn/index/fujiajia/xunzhang.png -->
					<image class="medal" :src="userInfo.user_fee_level" mode=""></image>
					<!-- <view class="post">
						<image class="gradient" src="https://app.yycjkb.cn/index/fujiajia/jianbian.png" mode="">
						</image>
						<view>业务员
						</view>
					</view> -->
				</view>
			</view>

			<!-- 錢包 -->
			<view class="money-bag">
				<image class="money-bag-image" src="https://app.yycjkb.cn/index/fujiajia/jianbianback.png"
					mode="">
				</image>
				<view class="money-bag-content">
					<view class="money-content-left">
						<view class="">
							<image src="#" mode=""></image>
							<text class="shopTitle">粉丝中心</text>
						</view>
						<view class="">
							<image src="#" mode=""></image>
							解锁所有权限
						</view>
					</view>
				</view>
			</view>

			<!-- 粉絲內容 -->
			<view class="small-assistant">
				<view class="fancy-content">
					<view class="fancy-item" v-for="item in list" @tap="tochild(item.uid)">
						<image class="cu-avatar round lg" :style="{'backgroundImage': 'url(' + (item.avatar || '/static/default_avatar.png') + ')'}" mode=""></image>
						<view class="phone">
							{{item.nickname}}<span style="color:red">{{item.user_level==2?'（商家）':item.user_level==3?'（创客）':''}}</span>
						</view>
						<view class="person"> 
							团队:{{item.total}}人
						</view>
					</view>
				</view>

				<!-- 返回按钮 -->
				<view class="back-button" @tap="toback()">
					返回
				</view>
			</view>
		</view>

		<!-- 底部tabbar -->
		<!-- <tabBar :selectIndex="selectIndex"></tabBar> -->
	</view>
</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex';
	import user from '@/api/user';
	import tabBar from "@/newsPage/components/tabBar/index.vue"
	export default {
		components: {
			tabBar
		},
		data() {
			return {
				selectIndex: 2,
				list: [],
				empty: false,
				count:0
			};
		},
		created() {
			this.loadData()
		},
		computed: {
			...mapState(['config', 'hasLogin', 'userInfo']),
		},
		methods: {
			toback(){
				uni.switchTab({
					url:'/pages/my/index'
				})
			},
			tochild(uid) {
				uni.navigateTo({
					url: '/pages/my/fans_list?uid=' + uid
				})
			},
			loadData() {
				user.fansList().then(res => {
					if (res.code === 1) {
						if (res.data.list.length <= 0) {
							this.empty = true;
							this.list = [];
						} else {
							this.empty = false;
							this.list = res.data.list;
							this.count = res.data.count
						}
					} else {
						this.empty = true;
						this.list = [];
						this.toast(res.msg);
					}
				})
			}
		}
	}
</script>

<style lang="less" scoped>
	.user-copy {
		font-size: 12px;
		letter-spacing: 0;
		background: #F8ACA9;
		color: #fff;
		border-radius: 20px;
		padding: 2px 6px;
		margin-left: 10px;
	}

	.login-btn {
		margin-left: 20px;
		font-size: 30rpx;
		background: transparent;
		border: none;
		color: #fff;
		outline: none;
		padding: 0;

		// width: 30%;
		&::after {
			display: none;
		}
	}

	.backImage {
		width: 100%;
		position: absolute;
		left: 0%;
	}

	.container {
		padding-top: 140rpx;
		padding-bottom: 20rpx;
		width: 690rpx;
		margin: auto;
		position: relative;

		.user-info {
			display: flex;
			justify-content: space-between;
			align-items: center;

			.user-info-left {
				display: flex;

				.user-info-image {
					width: 137rpx;
					height: 137rpx;
					border-radius: 100rpx;
				}

				.user-info-name {
					display: flex;
					justify-content: space-between;
					flex-direction: column;
					padding: 10rpx 20rpx;

					.info {
						color: #666666;
						font-size: 24rpx;
						line-height: 140%;
					}
				}
			}

			.user-info-right {
				text-align: center;
				display: flex;
				flex-direction: column;
				justify-content: center;
				align-items: center;

				.medal {
					width: 150rpx;
					height: 146rpx;
					margin-bottom: -5rpx;
				}

				.post {
					width: 98rpx;
					height: 38rpx;
					position: relative;
					color: #fff;
					padding: 10rpx 0;

					.gradient {
						width: 100%;
						height: 100%;
						position: absolute;
						left: 50%;
						transform: translate(-50%, 0);
					}

					view {
						z-index: 16;
						position: relative;
						line-height: 38rpx;
						transform: scale(0.8) !important;
						font-size: 16rpx;
					}
				}
			}
		}

		.money-bag {
			padding-top: 30rpx;

			.shopTitle {
				font-size: 30rpx;
				font-weight: bold;
			}

			.money-bag-image {
				width: 100%;
				height: 126rpx;
				position: absolute;
			}

			.money-bag-content {
				position: relative;
				padding: 0 30rpx;
				display: flex;
				justify-content: space-between;
				align-items: center;
				height: 126rpx;

				.money-content-left {
					color: #FFF;

					view {
						display: flex;
						align-items: center;
						font-size: 24rpx;
						padding: 4rpx 0;

						image {
							vertical-align: middle;
							margin-right: 10rpx;
							width: 34rpx;
							height: 34rpx;
						}
					}
				}
			}
		}

		.small-assistant {
			width: 100%;
			background-color: #fff;
			border-radius: 24rpx;
			margin-top: 30rpx;
			padding: 20rpx 30rpx;
			min-height: 975rpx;
			position: relative;

			.fancy-item {
				display: flex;
				align-items: center;
				width: 95%;
				margin: auto;
				justify-content: space-between;
				padding: 20rpx 0;

				image {
					width: 100rpx;
					height: 100rpx;
					border-radius: 100%;
				}

				.phone {
					font-size: 30rpx;
					width: 45%;
					text-align: left;
				}

				.person {
					width: 30%;
				}
			}

			.back-button {
				width: 230rpx;
				height: 76rpx;
				display: flex;
				justify-content: center;
				align-items: center;
				margin: 40rpx auto;
				margin-top: 50rpx;
				background: linear-gradient(90deg, rgba(254, 176, 122, 1) 35%, rgba(242, 171, 235, 1) 100%);
				border-radius: 20rpx;
				color: #fff;
				position: relative;
				bottom: 2%;
				// left: 50%;
				// transform: translateX(-50%);
			}
		}
	}
</style>